home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / v0_98 / shapiro-btx.bst < prev    next >
Text File  |  1990-10-02  |  57KB  |  2,302 lines

  1. %NAME: shapiro-btx.bst
  2. # if 0
  3. % BibTeX `plain' family
  4. % modified to ouput fields in French; shapiro@corto.inria.fr 30-oct-87
  5. % Further modified for 'alpha3' and 'long' styles 3-nov-87
  6. % and for 'key' and 'skey' 1-jan-88
  7. # endif 0
  8.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  9.     % Copyright (C) 1985, all rights reserved
  10.     % Copying of this file is authorized only if either
  11.     % (1) you make absolutely no changes to your copy, including name, or
  12.     % (2) if you do make changes, you name it something other than
  13.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  14.     % This restriction helps ensure that all standard styles are identical
  15. # if 0
  16. % This is file btxbxt.doc; it helps document bibliography styles,
  17. % and is also a template file that you can use to make
  18. % several different style files, if you have access to a C preprocessor.
  19. % For example, the standard styles were made by something like
  20. %    cpp -P -DPLAIN btxbst.doc | sed -e '/^$/d' > plain.bst
  21. %    cpp -P -DUNSRT btxbst.doc | sed -e '/^$/d' > unsrt.bst
  22. %    cpp -P -DALPHA btxbst.doc | sed -e '/^$/d' > alpha.bst
  23. %    cpp -P -DABBRV btxbst.doc | sed -e '/^$/d' > abbrv.bst
  24. % A French version of (say) abbrv is created by
  25. %    cpp -P -DABBRV -DFRENCH btxbst.doc | sed -e '/^$/d' > fabbrv.bst
  26. % There are also new styles created by defining ALPHA3, KEY, SKEY or LONG.
  27. %       ALPHA3 label is first 3 letters of 1st author's name + year
  28. %       LONG   label is 1st author's full name + year
  29. %       KEY    label is the bibtex key, the bibliogrpahy is unsorted
  30. %       SKEY   label is the bibtex key, sorted by 1st author's name&year
  31. % The last two styles are intended for printing the database itself.
  32. %
  33. % If you don't have access,
  34. % you can edit this file by hand to imitate the preprocessor,
  35. % with the following explanation of the C preprocessor constructs used here.
  36. %
  37. % The output of the preprocessor is the same as the input, except that certain
  38. % lines will be excluded (and some blank lines will be added).  The sequence
  39. %    #if VAR
  40. %        lines to be included when VAR is not zero
  41. %    #else
  42. %        lines to be included when VAR is zero
  43. %    #endif
  44. % (with the #-signs appearing in column 1) means that one set or the other of
  45. % the lines are to be included depending on the value of VAR.
  46. % The #else part is optional.  Comments can be added after #else and #endif.
  47. % The '# if 0' ... '#endif' sequence is used to eliminate unnecessary
  48. % comments from the output.
  49. % Variables can be set by
  50. %    #define VAR value
  51. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  52. % to see if it has none.
  53. % Another #if form used in this file is #if !VAR, which includes the lines
  54. % after the #if only if VAR is zero.
  55. %
  56. % Convention: Use all uppercase identifiers for these preprocessor variables
  57. % so you can spot them easily
  58. %
  59. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  60. % or ABBRV (though PLAIN will be used by default if none is given),
  61. % and the following lines will set various boolean variables to control the
  62. % various lines that are chosen from the rest of the file.
  63. % Each boolean variable should be set true (1) or false (0) in each style.
  64. % Here are the current variables, and their meanings:
  65. %    LAB_ALPH:    an alphabetic label is used (if false then a numeric
  66. %                label is used)
  67. %    SORTED:        the entries should be sorted by label (if nonnumeric)
  68. %                and other info, like authors (if false, then
  69. %                entries remain in order of occurrence)
  70. %    NAME_FULL:    the authors, editors, etc., get the full names as
  71. %                given in the bibliograph (if false, the first
  72. %                names become initials)
  73. %    ATIT_LOWER:    titles of non-"books" (e.g., articles) should be
  74. %                converted to lower-case, except the first letter
  75. %                (if false then they appear as in the database)
  76. %    MONTH_FULL:    months are spelled out in full (if false, then
  77. %                they're abbreviated)
  78. %    JOUR_FULL:    macro journal names are spelled out in full
  79. %                (if false then they are abbreviated, currently
  80. %                as they appear in ACM publications)
  81. %       LBKEYS:         use the database key as the citation label
  82. % Furthermore the variable ALPHA_LONG may have one of the following
  83. % values, when LAB_ALPH is 1, giving the following citation alphabetic
  84. % label format:
  85. % 0 [Lam85] for single author (or editor or key): first 3 letters of last name
  86. %   [SW79]  (first letters of last names) for multiple authors
  87. % 1 [Lam85] for single author (or editor or key)
  88. %   [Str79]  (first 3 letters of 1st author's last name) for multiple authors
  89. % 2 [Lamport 85] for single author (or editor or key): full last name
  90. %   [Strunk 79]  (full last name of 1st author) for multiple authors
  91. # endif 0
  92.  
  93. #ifndef UNSRT
  94. #   ifndef ALPHA
  95. #    ifndef ABBRV
  96. #           ifndef ALPHA3
  97. #               ifndef LONG
  98. #                   ifndef KEY
  99. #                       ifndef SKEY
  100. #                              define PLAIN 1
  101. #                       endif
  102. #                   endif
  103. #               endif
  104. #           endif
  105. #    endif
  106. #   endif
  107. #endif
  108. #ifdef PLAIN
  109. % plain style (sorted numbers)
  110. #   define LAB_ALPH 0
  111. #   define SORTED 1
  112. #   define NAME_FULL 1
  113. #   define ATIT_LOWER 1
  114. #   define MONTH_FULL 1
  115. #   define JOUR_FULL 1
  116. #   define LBKEYS 0
  117. #endif
  118. #ifdef UNSRT
  119. % unsrt style (unsorted numbers)
  120. #   define LAB_ALPH 0
  121. #   define SORTED 0
  122. #   define NAME_FULL 1
  123. #   define ATIT_LOWER 1
  124. #   define MONTH_FULL 1
  125. #   define JOUR_FULL 1
  126. #   define LBKEYS 0
  127. #endif
  128. #ifdef ALPHA
  129. % alpha style (sorted short alphabetics)
  130. #   define LAB_ALPH 1
  131. #   define ALPHA_LONG 0
  132. #   define SORTED 1
  133. #   define NAME_FULL 1
  134. #   define ATIT_LOWER 1
  135. #   define MONTH_FULL 1
  136. #   define JOUR_FULL 1
  137. #   define LBKEYS 0
  138. #endif
  139. #ifdef ALPHA3
  140. % alpha3 style (sorted short alphabetics, 3 letters of 1st author only)
  141. #   define LAB_ALPH 1
  142. #   define ALPHA_LONG 1
  143. #   define SORTED 1
  144. #   define NAME_FULL 1
  145. #   define ATIT_LOWER 1
  146. #   define MONTH_FULL 1
  147. #   define JOUR_FULL 1
  148. #   define LBKEYS 0
  149. #endif
  150. #ifdef LONG
  151. % long style (sorted long alphabetics, full name of 1st author only)
  152. #   define LAB_ALPH 1
  153. #   define ALPHA_LONG 2
  154. #   define SORTED 1
  155. #   define NAME_FULL 1
  156. #   define ATIT_LOWER 1
  157. #   define MONTH_FULL 1
  158. #   define JOUR_FULL 1
  159. #   define LBKEYS 0
  160. #endif
  161. #ifdef ABBRV
  162. % abbrv style (sorted numbers, with abbreviations)
  163. #   define LAB_ALPH 0
  164. #   define SORTED 1
  165. #   define JOUR_FULL 0
  166. #   define MONTH_FULL 0
  167. #   define ATIT_LOWER 1
  168. #   define NAME_FULL 0
  169. #   define LBKEYS 0
  170. #endif
  171. #ifdef KEY
  172. % keys style (unsorted keys)
  173. #   define LAB_ALPH 1
  174. #   define ALPHA_LONG 2
  175. #   define SORTED 0
  176. #   define NAME_FULL 0
  177. #   define ATIT_LOWER 1
  178. #   define MONTH_FULL 0
  179. #   define JOUR_FULL 1
  180. #   define LBKEYS 1
  181. #endif
  182. #ifdef SKEY
  183. % skeys style (keys, sorted by name of 1st author and year)
  184. #   define LAB_ALPH 1
  185. #   define ALPHA_LONG 2
  186. #   define SORTED 1
  187. #   define NAME_FULL 1
  188. #   define ATIT_LOWER 1
  189. #   define MONTH_FULL 0
  190. #   define JOUR_FULL 1
  191. #   define LBKEYS 1
  192. #endif
  193. #ifdef FRENCH
  194. % French version
  195. #endif FRENCH
  196. %
  197. # if 0
  198. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  199. %    in "A Handbook for Scholars".  Book-like titles are italicized and
  200. %    non-book titles are converted to sentence capitilization
  201. %    (and not enclosed in quotes).
  202. %    This file outputs a \newblock between major blocks of an entry
  203. %    (the name \newblock is analogous to the names \newline and \newpage)
  204. %    so that the user can obtain an "open" format, which has a line break
  205. %    before each block and lines after the first are indented within blocks,
  206. %    by giving an optional \documentstyle argument; currently there is a
  207. %    required `optional' \documentstyle argument, one of
  208. %        opbiba, opbibr, clbiba, or clbibr,
  209. %    giving an open or closed format for an article or report.
  210. %    For the next version of LaTeX there will be just one, truly optional
  211. %    style, for the open format
  212. %    (among other things, it will have improved page breaking).
  213. %    The default will be the "closed" format---blocks runs together.
  214. %
  215. %   Citation alphabetic label format:
  216. %        [Knu73] for single author (or editor or key)
  217. %        [AHU83] (first letters of last names) for multiple authors
  218. %
  219. %   Citation label numberic format:
  220. %        [number]
  221. %
  222. %   Reference list ordering for sorted, alphabetic lables:
  223. %        alphabetical by citation label, then by author(s) or whatever
  224. %        passes for author in the absence of one, and then by title.
  225. %
  226. %   Reference list ordering for sorted, numeric lables:
  227. %        alphabetical by author(s) or whatever passes
  228. %        passes for author in the absence of one, and then by title.
  229. %
  230. %   Reference list ordering for unsorted:
  231. %        by the order cited in the text
  232. %
  233. %   History
  234. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  235. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  236. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik
  237. %    2/17/85    (HWT)    template file and other standard styles made
  238. %    3/28/85        First release, version 0.98b for BibTeX 0.98f
  239. %    5/ 9/85        version 0.98c for BibTeX 0.98i
  240. %             : fixed Theoretical Computer Science macro name
  241. %             : fixed the format.vol.num.pages function
  242. %
  243. % The ENTRY declaration
  244. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  245. %   but no fullauthor or editors fields because BibTeX does name handling.
  246. %   The annote field is commented out here because this family doesn't
  247. %   include an annotated bibliography style
  248. # endif 0
  249.  
  250. ENTRY
  251. % Fields:
  252.   { address
  253. %        Publisher's address
  254. %    annote
  255. %        Long annotation used for annotated bibliographies (begins sentence)
  256.     author
  257. %        Name(s) of author(s), in BibTeX name format
  258.     booktitle
  259. %        Book title when the thing being referenced isn't the whole book.
  260. %        For book entries, the title field should be used instead.
  261.     chapter
  262. %        Chapter number
  263.     edition
  264. %        Edition of a book (e.g., "second")
  265.     editor
  266. %        Name(s) of editor(s), in BibTeX name format.
  267. %        If there is also an author field, then the editor field should be
  268. %        for the book or collection that the work appears in
  269.     howpublished
  270. %         How something strange has been published (begins sentence)
  271.     institution
  272. %        Sponsoring institution
  273.     journal
  274. %        Journal name (macros are provided for many)
  275.     key
  276. %        Alphabetizing and labeling key (needed when no author or editor)
  277.     month
  278. %        Month (macros are provided)
  279.     note
  280. %        To help the reader find a reference (begins sentence)
  281.     number
  282. %        Number of a journal or technical report
  283.     organization
  284. %        Organization (sponsoring a conference)
  285.     pages
  286. %        Page number or numbers (use `--' to separate a range)
  287.     publisher
  288. %        Publisher name
  289.     school
  290. %        School name (for theses)
  291.     series
  292. %        The name of a series or set of books.
  293. %        An individual book will will also have it's own title
  294.     title
  295. %        The title of the thing being referenced
  296.     type
  297. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  298. %        the default "Technical Report"
  299.     volume
  300. %        Volume of a journal or multivolume work
  301.     year
  302. %        Year---should contain only numerals
  303.   }
  304. # if 0
  305. % There are no integer entry variables
  306. # endif 0
  307.   {}
  308. # if 0
  309. % These string entry variables are used to form the citation label.
  310. % In a storage pinch, sort.label can be easily computed on the fly.
  311. # endif 0
  312.  
  313. #if LAB_ALPH
  314. #if SORTED
  315.   { label extra.label sort.label }
  316. #else !SORTED
  317. # if 0
  318. % It still doesn't seem like a good idea to use an order-of-citation
  319. % reference list when using alphabetic labels, but when this happens we
  320. % do things a little differently
  321. # endif 0
  322.   {label}
  323. #endif SORTED
  324. #else !LAB_ALPH
  325.   {label}
  326. #endif LAB_ALPH
  327.  
  328. # if 0
  329. % Each entry function starts by calling output.bibitem, to write the
  330. % \bibitem and its arguments to the .BBL file.  Then the various fields
  331. % are formatted and printed by output or output.check.  Those functions
  332. % handle the writing of separators (commas, periods, \newblock's),
  333. % taking care not to do so when they are passed a null string.
  334. % Finally, fin.entry is called to add the final period and finish the
  335. % entry.
  336. %
  337. % A bibliographic reference is formatted into a number of `blocks':
  338. % in the open format, a block begins on a new line and subsequent
  339. % lines of the block are indented.  A block may contain more than
  340. % one sentence (well, not a grammatical sentence, but something to
  341. % be ended with a sentence ending period).  The entry functions should
  342. % call new.block whenever a block other than the first is about to be
  343. % started.  They should call new.sentence whenever a new sentence is
  344. % to be started.  The output functions will ensure that if two
  345. % new.sentence's occur without any non-null string being output between
  346. % them then there won't be two periods output.  Similarly for two
  347. % successive new.block's.
  348. %
  349. % The output routines don't write their argument immediately.
  350. % Instead, by convention, that argument is saved on the stack to be
  351. % output next time (when we'll know what separator needs to come
  352. % after it).  Meanwhile, the output routine has to pop the pending
  353. % output off the stack, append any needed separator, and write it.
  354. %
  355. % To tell which separator is needed, we maintain an output.state.
  356. % It will be one of these values:
  357. %    before.all        just after the \bibitem
  358. %    mid.sentence        in the middle of a sentence: comma needed
  359. %                    if more sentence is output
  360. %    after.sentence        just after a sentence: period needed
  361. %    after.block        just after a block (and sentence):
  362. %                    period and \newblock needed.
  363. % Note: These styles don't use after.sentence
  364. %
  365. % VAR: output.state : INTEGER        -- state variable for output
  366. %
  367. % The output.nonnull function saves its argument (assumed to be nonnull)
  368. % on the stack, and writes the old saved value followed by any needed
  369. % separator.  The ordering of the tests is decreasing frequency of
  370. % occurrence.
  371. %
  372. % output.nonnull(s) ==
  373. %  BEGIN
  374. %    s := argument on stack
  375. %    if output.state = mid.sentence then
  376. %        write$(pop() * ", ")
  377. %          -- "pop" isn't a function: just use stack top
  378. %    else
  379. %        if output.state = after.block then
  380. %        write$(add.period$(pop()))
  381. %        newline$
  382. %        write$("\newblock ")
  383. %        else
  384. %        if output.state = before.all then
  385. %            write$(pop())
  386. %        else        -- output.state should be after.sentence
  387. %            write$(add.period$(pop()) * " ")
  388. %        fi
  389. %        fi
  390. %    fi
  391. %    push s on stack
  392. %    output.state := mid.sentence
  393. %  END
  394. %
  395. % The output function calls output.nonnull if its argument is non-null
  396. %
  397. % output(s) ==
  398. %  BEGIN
  399. %    if s <> "" then output.nonnull(s)
  400. %    fi
  401. %  END
  402. %
  403. % The output.check function calls output.nonnull if s is non-null
  404. % and warns the user that the t field shouldn't be empty (this is
  405. % because it won't be a good reference without the field;  the entry
  406. % functions try to make the formatting look reasonable even when such
  407. % fields are empty).
  408. %
  409. % output.check(t,s) ==
  410. %  BEGIN
  411. %    if s = "" then
  412. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  413. %    else output.nonnull(s)
  414. %    fi
  415. %  END
  416. %
  417. % The output.bibitem function writes the \bibitem for the current entry
  418. % (the label should already have been set up), and sets up the separator
  419. % state for the output functions.  And, it leaves a string on the stack
  420. % as per the output convention.
  421. %
  422. % output.bibitem ==
  423. %  BEGIN
  424. %    newline$
  425. %    write$("\bibitem[")    % for alphabetic labels,
  426. %    write$(label)        % these three lines
  427. %    write$("]{")        % are used
  428. %    write$("\bibitem{")        % this line for numeric labels
  429. %    write$(cite$)
  430. %    write$("}")
  431. %    push "" on stack
  432. %    output.state := before.all
  433. %  END
  434. %
  435. % The fin.entry function finishes off an entry by adding a period to the
  436. % string remaining on the stack.  If the state is still before.all
  437. % then nothing was produced for this entry, so the result will look bad,
  438. % but the user deserves it. (We don't omit the whole entry because the
  439. % entry was cited, and a bibitem is needed to define the citation label.)
  440. %
  441. % fin.entry ==
  442. %  BEGIN
  443. %    write$(add.period$(pop()))
  444. %    newline$
  445. %  END
  446. %
  447. % The new.block function prepares for a new block to be output, and
  448. % new.sentence prepares for a new sentence.
  449. %
  450. % new.block ==
  451. %  BEGIN
  452. %    if output.state <> before.all then
  453. %        output.state := after.block
  454. %    fi
  455. %  END
  456. %
  457. % new.sentence ==
  458. %  BEGIN
  459. %    if output.state <> after.block then
  460. %        if output.state <> before.all then
  461. %        output.state :=  after.sentence
  462. %        fi
  463. %    fi
  464. %  END
  465. %
  466. # endif 0
  467.  
  468. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  469.  
  470. FUNCTION {init.state.consts}
  471. { 'before.all #0 :=
  472.   'mid.sentence #1 :=
  473.   'after.sentence #2 :=
  474.   'after.block #3 :=
  475. }
  476.  
  477. # if 0
  478. % the variables s and t are temporary string holders
  479. # endif 0
  480.  
  481. STRINGS { s t }
  482.  
  483. FUNCTION {output.nonnull}
  484. { 's swap$ :=
  485.   output.state mid.sentence =
  486.     { ", " * write$ }
  487.     { output.state after.block =
  488.     { add.period$ write$
  489.       newline$
  490.       "\newblock " write$
  491.     }
  492.     { output.state before.all =
  493.         'write$
  494.         { add.period$ " " * write$ }
  495.       if$
  496.     }
  497.       if$
  498.     }
  499.   if$
  500.   'output.state mid.sentence :=
  501.   s
  502. }
  503.  
  504. FUNCTION {output}
  505. { 's swap$ :=
  506.   s "" =
  507.     'skip$
  508.     { s output.nonnull }
  509.   if$
  510. }
  511.  
  512. FUNCTION {output.check}
  513. { 's swap$ :=
  514.   't swap$ :=
  515.   s "" =
  516.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  517.     { s output.nonnull }
  518.   if$
  519. }
  520.  
  521. FUNCTION {output.bibitem}
  522. { newline$
  523. #if LAB_ALPH
  524.   "\bibitem[" write$
  525.   label write$
  526.   "]{" write$
  527. #else
  528.   "\bibitem{" write$
  529. #endif
  530.   cite$ write$
  531.   "}" write$
  532.   newline$
  533.   ""
  534.   'output.state before.all :=
  535. }
  536.  
  537. # if 0
  538. % This function finishes all entries.  Note: For an otherwise empty entry
  539. % (which is probably due to a user error) this function prints a
  540. period
  541. # endif 0
  542.  
  543. FUNCTION {fin.entry}
  544. { add.period$
  545.   write$
  546.   newline$
  547. }
  548.  
  549. FUNCTION {new.block}
  550. { output.state before.all =
  551.     'skip$
  552.     { 'output.state after.block := }
  553.   if$
  554. }
  555.  
  556. # if 0
  557. % This function isn't used in these styles
  558. # endif 0
  559.  
  560. FUNCTION {new.sentence}
  561. { output.state after.block =
  562.     'skip$
  563.     { output.state before.all =
  564.     'skip$
  565.     { 'output.state after.sentence := }
  566.       if$
  567.     }
  568.   if$
  569. }
  570.  
  571. # if 0
  572. % These three functions pop one or two (integer) arguments from the stack
  573. % and push a single one, either 0 or 1.
  574. % The 'skip$ in the `and' and `or' functions are used because
  575. % the corresponding if$ would be idempotent
  576. # endif 0
  577.  
  578. FUNCTION {not}
  579. {   { #0 }
  580.     { #1 }
  581.   if$
  582. }
  583.  
  584. FUNCTION {and}
  585. {   'skip$
  586.     { pop$ #0 }
  587.   if$
  588. }
  589.  
  590. FUNCTION {or}
  591. {   { pop$ #1 }
  592.     'skip$
  593.   if$
  594. }
  595.  
  596. # if 0
  597. % Here are some functions for formatting chunks of an entry.
  598. % By convention they either produce a string that can be followed by
  599. % a comma or period (using add.period$, so it is OK to end in a period),
  600. % or they produce the null string.
  601. %
  602. % A useful utility is the field.or.null function, which checks if the
  603. % argument is the result of pushing a `missing' field (one for which no
  604. % assignment was made when the current entry was read in from the database),
  605. % and returns the null string if so, otherwise it returns the field string.
  606. %
  607. % field.or.null(s) ==
  608. %  BEGIN
  609. %    if missing$(s) then return ""
  610. %    else return s
  611. %  END
  612. %
  613. % Another helper function is italicize, which returns the string that
  614. % italicizes the argument string, if that is non-null, otherwise it
  615. % returns the null string.  Italic corrections aren't used, so this
  616. % function should be used when punctation will follow the result.
  617. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  618. % emphasizing the whole bibliography.
  619. %
  620. % italicize(s) ==
  621. %  BEGIN
  622. %    if s = "" then return ""
  623. %    else return "{\it " * s * "}"
  624. %
  625. % The format.names function formats the argument (which should be in
  626. % BibTeX name format) into "First Von~Last, Junior", separated by commas
  627. % and with an "and" before the last (but ending with "et al." if the last
  628. % of multiple authors is "others")
  629. %
  630. % VAR: nameptr, namesleft, numnames: INTEGER
  631. %      nameresult: STRING
  632. %
  633. % format.names(s) ==
  634. %  BEGIN
  635. %    nameptr := 1
  636. %    nameresult := ""
  637. %    numnames := num.names$(s)
  638. %    namesleft := numnames
  639. %    while namesleft > 0
  640. %      do
  641. %                % for full names:
  642. %        t := format.name$(s, nameptr, "{ff }{vv~}{ll}{, jj}")
  643. %                % for abbreviated first names:
  644. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  645. %        if nameptr > 1 then
  646. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  647. %        else if numnames > 2
  648. %               then nameresult := nameresult * ","
  649. %             fi
  650. %             if t = "others"
  651. %               then nameresult := nameresult * " et al."
  652. %               else nameresult := nameresult * " and " * t
  653. %             fi
  654. %        fi
  655. %        else nameresult := nameresult * t
  656. %        fi
  657. %        nameptr := nameptr + 1
  658. %        namesleft := namesleft - 1
  659. %      od
  660. %    return nameresult
  661. %  END
  662. %
  663. % The format.authors function returns the result of format.names(author)
  664. % if the author is present, or else it returns the null string
  665. %
  666. % format.authors ==
  667. %  BEGIN
  668. %    if missing$(author) then return ""
  669. %    else return format.names(author)
  670. %    fi
  671. %  END
  672. %
  673. % Format.editors is like format.authors, but it uses the editor field,
  674. % and appends ", editor" or ", editors"
  675. %
  676. % format.editors ==
  677. %  BEGIN
  678. %    if missing$(editor) then return ""
  679. %    else
  680. %        if num.names$(editor) > 1 then
  681. %        return format.names(editor) * ", editors"
  682. %        else
  683. %        return format.names(editor) * ", editor"
  684. %        fi
  685. %    fi
  686. %  END
  687. %
  688. % Other formatting functions are similar, so no "comment version" will be
  689. % given for them.
  690. %
  691. % The `pop$' in this function gets rid of the duplicate `missing' value and
  692. % the `skip$' returns the duplicate field value
  693. # endif 0
  694.  
  695. FUNCTION {field.or.null}
  696. { duplicate$
  697.   missing$
  698.     { pop$ "" }
  699.     'skip$
  700.   if$
  701. }
  702.  
  703. FUNCTION {italicize}
  704. { 's swap$ :=
  705.   s "" =
  706.     { "" }
  707.     { "{\it " s * "}" * }
  708.   if$
  709. }
  710.  
  711. INTEGERS { nameptr namesleft numnames }
  712.  
  713. STRINGS {nameresult}
  714.  
  715. FUNCTION {format.names}
  716. { 's swap$ :=
  717.   'nameptr #1 :=
  718.   'nameresult "" :=
  719.   'numnames s num.names$ :=
  720.   'namesleft numnames :=
  721.     { namesleft #0 > }
  722.     {
  723. #if NAME_FULL
  724.       't s nameptr "{ff }{vv~}{ll}{, jj}" format.name$ :=
  725. #else
  726.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  727. #endif
  728.       nameptr #1 >
  729.     { namesleft #1 >
  730.         { 'nameresult nameresult ", " * t * := }
  731.         { numnames #2 >
  732.         { 'nameresult nameresult "," * := }
  733.         'skip$
  734.           if$
  735.           t "others" =
  736.         { 'nameresult nameresult " et al." * := }
  737. #ifndef FRENCH
  738.         { 'nameresult nameresult " and " * t * := }
  739. #else FRENCH
  740.         { 'nameresult nameresult " et " * t * := }
  741. #endif FRENCH
  742.           if$
  743.         }
  744.       if$
  745.     }
  746.     { 'nameresult nameresult t * := }
  747.       if$
  748.       'nameptr nameptr #1 + :=
  749.       'namesleft namesleft #1 - :=
  750.     }
  751.   while$
  752.   nameresult
  753. }
  754.  
  755. FUNCTION {format.authors}
  756. { author missing$
  757.     { "" }
  758.     { author format.names }
  759.   if$
  760. }
  761.  
  762. FUNCTION {format.editors}
  763. { editor missing$
  764.     { "" }
  765.     { editor num.names$ #1 >
  766. #ifndef FRENCH
  767.     { editor format.names ", editors" * }
  768.     { editor format.names ", editor" * }
  769. #else FRENCH
  770.     { editor format.names ", \'{e}diteurs" * }
  771.     { editor format.names ", \'{e}diteur" * }
  772. #endif FRENCH
  773.       if$
  774.     }
  775.   if$
  776. }
  777.  
  778. # if 0
  779. % The format.title function is used for non-book-like titles.
  780. % For most styles we convert to lowercase (except for the very first letter),
  781. % and hope the user has brace-surrounded words that need to stay capitilized;
  782. % for some, however, we leave it as it is in the database.
  783. # endif 0
  784.  
  785. FUNCTION {format.title}
  786. #if ATIT_LOWER
  787. { title missing$
  788.     { "" }
  789.     { title "ul" change.case$ }
  790.   if$
  791. #else
  792. { title field.or.null
  793. #endif ATIT_LOWER
  794. }
  795.  
  796. # if 0
  797. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  798. % the maximum length of an entry string variable.
  799. %
  800. % The global.string.max function is set to BibTeX's glob_str_size constant,
  801. % the maximum length of a global string variable.
  802. # endif 0
  803.  
  804. FUNCTION {entry.string.max} { #100 }
  805.  
  806. FUNCTION {global.string.max} { #300 }
  807.  
  808. # if 0
  809. % The n.dashify function makes each single `-' in a string a double `--'
  810. % if it's not already
  811. %
  812. % VAR: pageresult: STRING
  813. %
  814. % n.dashify(s) ==
  815. %  BEGIN
  816. %    t := s
  817. %    pageresult := ""
  818. %    while (not (t = ""))
  819. %      do
  820. %        if (first character of t = "-")
  821. %          then
  822. %        if (next character isn't)
  823. %          then
  824. %            pageresult := pageresult * "--"
  825. %            t := t with the "-" removed
  826. %          else
  827. %            while (first character of t = "-")
  828. %              do
  829. %            pageresult := pageresult * "-"
  830. %            t := t with the "-" removed
  831. %              od
  832. %        fi
  833. %          else
  834. %        pageresult := pageresult * the first character
  835. %        t := t with the first character removed
  836. %        fi
  837. %      od
  838. %    return pageresult
  839. %  END
  840. # endif 0
  841.  
  842. STRINGS {pageresult}
  843.  
  844. FUNCTION {n.dashify}
  845. { 't swap$ :=
  846.   'pageresult "" :=
  847.     { t "" = not }
  848.     { t #1 #1 substring$ "-" =
  849.     { t #1 #2 substring$ "--" = not
  850.         { 'pageresult pageresult "--" * :=
  851.           't t #2 global.string.max substring$ :=
  852.         }
  853.         {   { t #1 #1 substring$ "-" = }
  854.         { 'pageresult pageresult "-" * :=
  855.           't t #2 global.string.max substring$ :=
  856.         }
  857.           while$
  858.         }
  859.       if$
  860.     }
  861.     { 'pageresult pageresult t #1 #1 substring$ * :=
  862.       't t #2 global.string.max substring$ :=
  863.     }
  864.       if$
  865.     }
  866.   while$
  867.   pageresult
  868. }
  869.  
  870. # if 0
  871. % The format.date function is for the month and year, but we give a warning if
  872. % there's a missing year but the month is there, and we return the empty string
  873. % if they're both missing
  874. # endif 0
  875.  
  876. FUNCTION {format.date}
  877. { year missing$
  878.     { month missing$
  879.     { "" }
  880.     { "Warning: there's a month but no year in " cite$ * top$
  881.       month
  882.     }
  883.       if$
  884.     }
  885.     { month missing$
  886.     { year }
  887.     { month " " * year * }
  888.       if$
  889.     }
  890.   if$
  891. }
  892.  
  893. # if 0
  894. % The format.btitle is for formatting the title field when it is a book-like
  895. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  896. # endif 0
  897.  
  898. FUNCTION {format.btitle}
  899. { title field.or.null
  900.   italicize
  901. }
  902.  
  903. # if 0
  904. % The format.bvolume function is for formatting the volume number and/or
  905. % series name of a multivolume book.  If the volume field is missing, we
  906. % output either the series field italicized if it exists or the null string
  907. % otherwise.  If both the volume and series fields are there, we assume the
  908. % series field is the title of the whole multivolume work (the title field
  909. % should be the title of the one referred to), and add an "of <series>".
  910. % A tie (~) is put between the "Volume" and the volume number.
  911. % We capitilize Volume because this function is used at the beginning of a
  912. % block.
  913. # endif 0
  914.  
  915. FUNCTION {format.bvolume}
  916. { volume missing$
  917.     { series missing$
  918.     { "" }
  919.     { series italicize }
  920.       if$
  921.     }
  922.     { "Volume~" volume *
  923.       series missing$
  924.     'skip$
  925. #ifndef FRENCH
  926.     { " of " * series italicize * }
  927. #else FRENCH
  928.     { ", s\'{e}rie " * series italicize * }
  929. #endif FRENCH
  930.       if$
  931.     }
  932.   if$
  933. }
  934.  
  935. # if 0
  936. % The format.edition function appends " edition" to the edition, if present.
  937. % We lowercase the edition (it should be something like "Third"), because
  938. % this doesn't start a sentence.
  939. # endif 0
  940.  
  941. FUNCTION {format.edition}
  942. { edition missing$
  943.     { "" }
  944. #ifndef FRENCH
  945.     { edition "ll" change.case$ " edition" * }
  946. #else FRENCH
  947.     { edition "ll" change.case$ " \'{e}dition" * }
  948. #endif FRENCH
  949.   if$
  950. }
  951.  
  952. # if 0
  953. % The format.pages function is used for formatting a page range in a book
  954. % (and in rare circumstances, an article).
  955. % The multi.page.check function examines the page field for a "-" or a ","
  956. % so that format.pages can use "page" instead of "pages" if neither exists.
  957. % Note: global.string.max, set above, here means "take the rest of the string"
  958. %
  959. % VAR: multiresult: INTEGER    (actually, a boolean)
  960. %
  961. % multi.page.check(s) ==
  962. %  BEGIN
  963. %    t := s
  964. %    multiresult := false
  965. %    while ((not multiresult) and (not (t = "")))
  966. %      do
  967. %        if (first character of t = "-" or ",")
  968. %          then multiresult := true
  969. %          else t := t with the first character removed
  970. %        fi
  971. %      od
  972. %    return multiresult
  973. %  END
  974. # endif 0
  975.  
  976. INTEGERS {multiresult}
  977.  
  978. FUNCTION {multi.page.check}
  979. { 't swap$ :=
  980.   'multiresult #0 :=
  981.     { multiresult not
  982.       t "" = not
  983.       and
  984.     }
  985.     { t #1 #1 substring$ "-" =
  986.       t #1 #1 substring$ "," =
  987.       or
  988.     { 'multiresult #1 := }
  989.     { 't t #2 global.string.max substring$ := }
  990.       if$
  991.     }
  992.   while$
  993.   multiresult
  994. }
  995.  
  996. # if 0
  997. % This function doesn't begin a sentence so "pages" isn't capitalized
  998. % other functions that use this should keep that in mind
  999. # endif 0
  1000.  
  1001. FUNCTION {format.pages}
  1002. { pages missing$
  1003.     { "" }
  1004.     { pages multi.page.check
  1005.     { "pages~" pages n.dashify * }
  1006.     { "page~" pages n.dashify * }
  1007.       if$
  1008.     }
  1009.   if$
  1010. }
  1011.  
  1012. # if 0
  1013. % The format.vol.num.pages function is for the volume, number, and page range
  1014. % of a journal article.  We use the format:  vol(number):pages, with minor
  1015. % variations for missing fields.  This doesn't begin a sentence.
  1016. # endif 0
  1017.  
  1018. FUNCTION {format.vol.num.pages}
  1019. { volume field.or.null
  1020.   number missing$
  1021.     'skip$
  1022.     { "(" number * ")" * *
  1023.       volume missing$
  1024.     { "Warning: there's a number but no volume in " cite$ * top$ }
  1025.     'skip$
  1026.       if$
  1027.     }
  1028.   if$
  1029.   pages missing$
  1030.     'skip$
  1031.     { duplicate$ "" =
  1032.     'skip$
  1033.     { ":" * }
  1034.       if$
  1035.       pages n.dashify *
  1036.     }
  1037.   if$
  1038. }
  1039.  
  1040. # if 0
  1041. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  1042. % if present, and then appends the pages, if present.
  1043. % This doesn't begin a sentence.
  1044. # endif 0
  1045.  
  1046. FUNCTION {format.chapter.pages}
  1047. { chapter missing$
  1048.     'format.pages
  1049. #ifndef FRENCH
  1050.     { "chapter~" chapter *
  1051. #else FRENCH
  1052.     { "chapitre~" chapter *
  1053. #endif FRENCH
  1054.       pages missing$
  1055.     'skip$
  1056.     { ", " * format.pages * }
  1057.       if$
  1058.     }
  1059.   if$
  1060. }
  1061.  
  1062. # if 0
  1063. % The format.in.ed.booktitle function is used for starting out a sentence
  1064. % that begins "In <booktitle>", putting an editor before the title if one
  1065. % exists.
  1066. # endif 0
  1067.  
  1068. FUNCTION {format.in.ed.booktitle}
  1069. { booktitle missing$
  1070.     { "" }
  1071.     { 's format.editors :=
  1072.       s "" =
  1073. #ifndef FRENCH
  1074.     { "In " booktitle italicize * }
  1075.     { "In " s * ", " * booktitle italicize * }
  1076. #else FRENCH
  1077.     { "Dans " booktitle italicize * }
  1078.     { "Dans " s * ", " * booktitle italicize * }
  1079. #endif FRENCH
  1080.       if$
  1081.     }
  1082.   if$
  1083. }
  1084.  
  1085. # if 0
  1086. % The format.tr.number makes a string starting with "Technical Report"
  1087. % (or type, if that field is defined), followed by the number if there
  1088. % is one (but return the first part even if there is no number)
  1089. # endif 0
  1090.  
  1091. FUNCTION {format.tr.number}
  1092. { type missing$
  1093. #ifndef FRENCH
  1094.     { "Technical Report" }
  1095. #else FRENCH
  1096.     { "Rapport" }
  1097. #endif FRENCH
  1098.     { type }
  1099.   if$
  1100.   number missing$
  1101.     'skip$
  1102. #ifndef FRENCH
  1103.     { "~" * number * }
  1104. #else FRENCH
  1105.     { " no.~" * number * }
  1106. #endif FRENCH
  1107.   if$
  1108. }
  1109.  
  1110. # if 0
  1111. % Now we define the type functions for all entry types that may appear
  1112. % in the .BIB file---e.g., functions like `book' and `article'.  These
  1113. % are the routines that actually generate the .BBL-file output for
  1114. % the entry.  These must all precede the READ command.  In addition, the
  1115. % style designer should have a function `default.type' for unknown types.
  1116. % Note: The fields (within each list) are listed in order of appearance,
  1117. % except as described for a `proceedings'.
  1118. %
  1119. % The article function is for an article in a journal.
  1120. %    Required fields: author, title, journal, year
  1121. %    Optional fields: volume, number, pages, month, note
  1122. %
  1123. % article ==
  1124. %  BEGIN
  1125. %    output.bibitem
  1126. %    output.check("author",format.authors)
  1127. %    new.block
  1128. %    output.check("title",format.title)
  1129. %    new.block
  1130. %    output.check("journal",italicize(field.or.null(journal)))
  1131. %    output(format.vol.num.pages)
  1132. %    output.check("year",format.date)
  1133. %    new.block
  1134. %    output(field.or.null(note))
  1135. %    fin.entry
  1136. %  END
  1137. %
  1138. % The book function is for a whole book.
  1139. %    Required fields: author or editor, title, publisher, year
  1140. %    Optional fields: volume, series, address, edition, month, note
  1141. %
  1142. % book ==
  1143. %  BEGIN
  1144. %    if missing$(author) then output.check("author and editor",
  1145. %                                format.editors)
  1146. %    else output.check("author",format.authors)
  1147. %    fi
  1148. %    new.block
  1149. %    output.check("title",format.btitle)
  1150. %    new.block
  1151. %    output(format.bvolume)
  1152. %    output.check("publisher",field.or.null(publisher))
  1153. %    output(field.or.null(address))
  1154. %    output(format.edition)
  1155. %    output.check("year",format.date))
  1156. %    new.block
  1157. %    output(field.or.null(note))
  1158. %    fin.entry
  1159. %  END
  1160. %
  1161. % The other entry functions are all quite similar, so no "comment version"
  1162. % will be given for them.
  1163. # endif 0
  1164.  
  1165. FUNCTION {article}
  1166. { output.bibitem
  1167.   "author" format.authors output.check
  1168.   new.block
  1169.   "title" format.title output.check
  1170.   new.block
  1171.   "journal" journal field.or.null italicize output.check
  1172.   format.vol.num.pages output
  1173.   "year" format.date output.check
  1174.   new.block
  1175.   note field.or.null output
  1176.   fin.entry
  1177. }
  1178.  
  1179. FUNCTION {book}
  1180. { output.bibitem
  1181.   author missing$
  1182.     { "author and editor" format.editors output.check }
  1183.     { "author" format.authors output.check }
  1184.   if$
  1185.   new.block
  1186.   "title" format.btitle output.check
  1187.   new.block
  1188.   format.bvolume output
  1189.   "publisher" publisher field.or.null output.check
  1190.   address field.or.null output
  1191.   format.edition output
  1192.   "year" format.date output.check
  1193.   new.block
  1194.   note field.or.null output
  1195.   fin.entry
  1196. }
  1197.  
  1198. # if 0
  1199. % A booklet is a bound thing without a publisher or sponsoring institution
  1200. %    Required: title
  1201. %    Optional: author, howpublished, address, month, year, note
  1202. # endif 0
  1203.  
  1204. FUNCTION {booklet}
  1205. { output.bibitem
  1206.   format.authors output
  1207.   new.block
  1208.   "title" format.btitle output.check
  1209.   new.block
  1210.   howpublished field.or.null output
  1211.   address field.or.null output
  1212.   format.date output
  1213.   new.block
  1214.   note field.or.null output
  1215.   fin.entry
  1216. }
  1217.  
  1218. # if 0
  1219. % For the conference entry type, see inproceedings
  1220. # endif 0
  1221.  
  1222. # if 0
  1223. % An inbook is a piece of a book: either a chapter and/or a page range.
  1224. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1225. %    Optional: volume, series, address, edition, month, note
  1226. # endif 0
  1227.  
  1228. FUNCTION {inbook}
  1229. { output.bibitem
  1230.   author missing$
  1231.     { "author and editor" format.editors output.check }
  1232.     { "author" format.authors output.check }
  1233.   if$
  1234.   new.block
  1235.   "title" format.btitle output.check
  1236.   "chapter and pages" format.chapter.pages output.check
  1237.   new.block
  1238.   format.bvolume output
  1239.   "publisher" publisher field.or.null output.check
  1240.   address field.or.null output
  1241.   format.edition output
  1242.   "year" format.date output.check
  1243.   new.block
  1244.   note field.or.null output
  1245.   fin.entry
  1246. }
  1247.  
  1248. # if 0
  1249. % An incollection is like inbook, but where there is a separate title
  1250. % for the referenced thing (and perhaps an editor for the whole)
  1251. %    Required: author, title, booktitle, publisher, year
  1252. %    Optional: editor, chapter, pages, address, month, note
  1253. # endif 0
  1254.  
  1255. FUNCTION {incollection}
  1256. { output.bibitem
  1257.   "authors" format.authors output.check
  1258.   new.block
  1259.   "title" format.title output.check
  1260.   new.block
  1261.   "booktitle" format.in.ed.booktitle output.check
  1262.   format.chapter.pages output
  1263.   "publisher" publisher field.or.null output.check
  1264.   address field.or.null output
  1265.   "year" format.date output.check
  1266.   new.block
  1267.   note field.or.null output
  1268.   fin.entry
  1269. }
  1270.  
  1271. # if 0
  1272. % An inproceedings is an article in a conference proceedings
  1273. %    Required: author, title, booktitle, year
  1274. %    Optional: editor, pages, organization, publisher, address, month, note
  1275. # endif 0
  1276.  
  1277. FUNCTION {inproceedings}
  1278. { output.bibitem
  1279.   "author" format.authors output.check
  1280.   new.block
  1281.   "title" format.title output.check
  1282.   new.block
  1283.   "booktitle" format.in.ed.booktitle output.check
  1284.   format.pages output
  1285.   organization field.or.null output
  1286.   publisher field.or.null output
  1287.   address field.or.null output
  1288.   "year" format.date output.check
  1289.   new.block
  1290.   note field.or.null output
  1291.   fin.entry
  1292. }
  1293.  
  1294. # if 0
  1295. % The conference function is included for Scribe compatibility
  1296. # endif 0
  1297.  
  1298. FUNCTION {conference} { inproceedings }
  1299.  
  1300. # if 0
  1301. % A manual is technical documentation
  1302. %    Required: title
  1303. %    Optional: author, organization, address, edition, month, year, note
  1304. # endif 0
  1305.  
  1306. FUNCTION {manual}
  1307. { output.bibitem
  1308.   format.authors output
  1309.   new.block
  1310.   "title" format.btitle output.check
  1311.   new.block
  1312.   organization field.or.null output
  1313.   address field.or.null output
  1314.   format.edition output
  1315.   format.date output
  1316.   new.block
  1317.   note field.or.null output
  1318.   fin.entry
  1319. }
  1320.  
  1321. # if 0
  1322. % A mastersthesis is a Master's thesis
  1323. %    Required: author, title, school, year
  1324. %    Optional: address, month, note
  1325. # endif 0
  1326.  
  1327. FUNCTION {mastersthesis}
  1328. { output.bibitem
  1329.   "author" format.authors output.check
  1330.   new.block
  1331.   "title" format.btitle output.check
  1332.   new.block
  1333. #ifndef FRENCH
  1334.   "Master's thesis" output
  1335. #else FRENCH
  1336.   "Rapport de ma\^{\i}trise" output
  1337. #endif FRENCH
  1338.   "school" school field.or.null output.check
  1339.   address field.or.null output
  1340.   "year" format.date output.check
  1341.   new.block
  1342.   note field.or.null output
  1343.   fin.entry
  1344. }
  1345.  
  1346. # if 0
  1347. % added for France: rapport de DEA, like master's thesis
  1348. # endif 0
  1349.  
  1350. FUNCTION {deathesis}
  1351. { output.bibitem
  1352.   "author" format.authors output.check
  1353.   new.block
  1354.   "title" format.btitle output.check
  1355.   new.block
  1356. #ifdef FRENCH
  1357.   "Rapport de DEA" output
  1358. #else
  1359.   "Dipl\^{o}me d'Etudes Approfondies Thesis" output
  1360. #endif FRENCH
  1361.   "school" school field.or.null output.check
  1362.   address field.or.null output
  1363.   "year" format.date output.check
  1364.   new.block
  1365.   note field.or.null output
  1366.   fin.entry
  1367. }
  1368.  
  1369. # if 0
  1370. % a misc is something that doesn't fit elsewhere
  1371. %    Required: none
  1372. %    Optional: author, title, howpublished, month, year, note
  1373. # endif 0
  1374.  
  1375. FUNCTION {misc}
  1376. { output.bibitem
  1377.   format.authors output
  1378.   new.block
  1379.   format.title output
  1380.   new.block
  1381.   howpublished field.or.null output
  1382.   format.date output
  1383.   new.block
  1384.   note field.or.null output
  1385.   fin.entry
  1386. }
  1387.  
  1388. # if 0
  1389. % A phdthesis is like a mastersthesis
  1390. %    Required: author, title, school, year
  1391. %    Optional: address, month, note
  1392. # endif 0
  1393.  
  1394. FUNCTION {phdthesis}
  1395. { output.bibitem
  1396.   "author" format.authors output.check
  1397.   new.block
  1398.   "title" format.btitle output.check
  1399.   new.block
  1400. #ifndef FRENCH
  1401.   "PhD thesis" output
  1402. #else FRENCH
  1403.   "Th\`{e}se de Doctorat" output
  1404. #endif FRENCH
  1405.   "school" school field.or.null output.check
  1406.   address field.or.null output
  1407.   "year" format.date output.check
  1408.   new.block
  1409.   note field.or.null output
  1410.   fin.entry
  1411. }
  1412.  
  1413. # if 0
  1414. % a proceedings is a conference proceedings
  1415. % if there is an organization but no editor field, the organization will
  1416. % appear as the first optional field (we try to make the first block nonempty)
  1417. %    Required: title, year
  1418. %    Optional: editor, publisher, organization, address, month, note
  1419. # endif 0
  1420.  
  1421. FUNCTION {proceedings}
  1422. { output.bibitem
  1423.   editor missing$
  1424.     { organization missing$
  1425.     'skip$
  1426.     { organization field.or.null output }
  1427.       if$
  1428.     }
  1429.     { format.editors output }
  1430.   if$
  1431.   new.block
  1432.   "title" format.btitle output.check
  1433.   editor missing$
  1434.     'skip$
  1435.     { organization field.or.null output }
  1436.   if$
  1437.   publisher field.or.null output
  1438.   address field.or.null output
  1439.   "year" format.date output.check
  1440.   new.block
  1441.   note field.or.null output
  1442.   fin.entry
  1443. }
  1444.  
  1445. # if 0
  1446. % a techreport is a technical report.
  1447. %    Required: author, title, institution, year
  1448. %    Optional: type, number, address, month, note
  1449. # endif 0
  1450.  
  1451. FUNCTION {techreport}
  1452. { output.bibitem
  1453.   "author" format.authors output.check
  1454.   new.block
  1455.   "title" format.btitle output.check
  1456.   new.block
  1457.   format.tr.number output
  1458.   "institution" institution field.or.null output.check
  1459.   address field.or.null output
  1460.   "year" format.date output.check
  1461.   new.block
  1462.   note field.or.null output
  1463.   fin.entry
  1464. }
  1465.  
  1466. # if 0
  1467. % an unpublished is something that hasn't been published
  1468. %    Required: author, title, note
  1469. %    Optional: month, year
  1470. # endif 0
  1471.  
  1472. FUNCTION {unpublished}
  1473. { output.bibitem
  1474.   "author" format.authors output.check
  1475.   new.block
  1476.   "title" format.title output.check
  1477.   new.block
  1478.   format.date output
  1479.   new.block
  1480.   "note" note field.or.null output.check
  1481.   fin.entry
  1482. }
  1483.  
  1484. # if 0
  1485. % We use entry type book for an unknown type and give a warning
  1486. # endif 0
  1487.  
  1488. FUNCTION {default.type} { book }
  1489.  
  1490. # if 0
  1491. % Here are macros for common things that may vary from style to style.
  1492. % Users are encouraged to use these macros.
  1493. %
  1494. % Months are either written out in full or abbreviated
  1495. # endif 0
  1496.  
  1497. #if MONTH_FULL
  1498.  
  1499. #ifndef FRENCH
  1500. MACRO {jan} {"January"}
  1501. #else FRENCH
  1502. MACRO {jan} {"janvier"}
  1503. #endif FRENCH
  1504.  
  1505. #ifndef FRENCH
  1506. MACRO {feb} {"February"}
  1507. #else FRENCH
  1508. MACRO {feb} {"f\'{e}vrier"}
  1509. #endif FRENCH
  1510.  
  1511. #ifndef FRENCH
  1512. MACRO {mar} {"March"}
  1513. #else FRENCH
  1514. MACRO {mar} {"mars"}
  1515. #endif FRENCH
  1516.  
  1517. #ifndef FRENCH
  1518. MACRO {apr} {"April"}
  1519. #else FRENCH
  1520. MACRO {apr} {"avril"}
  1521. #endif FRENCH
  1522.  
  1523. #ifndef FRENCH
  1524. MACRO {may} {"May"}
  1525. #else FRENCH
  1526. MACRO {may} {"mai"}
  1527. #endif FRENCH
  1528.  
  1529. #ifndef FRENCH
  1530. MACRO {jun} {"June"}
  1531. #else FRENCH
  1532. MACRO {jun} {"juin"}
  1533. #endif FRENCH
  1534.  
  1535. #ifndef FRENCH
  1536. MACRO {jul} {"July"}
  1537. #else FRENCH
  1538. MACRO {jul} {"juillet"}
  1539. #endif FRENCH
  1540.  
  1541. #ifndef FRENCH
  1542. MACRO {aug} {"August"}
  1543. #else FRENCH
  1544. MACRO {aug} {"ao\^{u}t"}
  1545. #endif FRENCH
  1546.  
  1547. #ifndef FRENCH
  1548. MACRO {sep} {"September"}
  1549. #else FRENCH
  1550. MACRO {sep} {"septembre"}
  1551. #endif FRENCH
  1552.  
  1553. #ifndef FRENCH
  1554. MACRO {oct} {"October"}
  1555. #else FRENCH
  1556. MACRO {oct} {"octobre"}
  1557. #endif FRENCH
  1558.  
  1559. #ifndef FRENCH
  1560. MACRO {nov} {"November"}
  1561. #else FRENCH
  1562. MACRO {nov} {"novembre"}
  1563. #endif FRENCH
  1564.  
  1565. #ifndef FRENCH
  1566. MACRO {dec} {"December"}
  1567. #else FRENCH
  1568. MACRO {dec} {"d\'{e}cembre"}
  1569. #endif FRENCH
  1570.  
  1571. #else !MONTH_FULL
  1572.  
  1573. #ifndef FRENCH
  1574. MACRO {jan} {"Jan."}
  1575. #else FRENCH
  1576. MACRO {jan} {"jan."}
  1577. #endif FRENCH
  1578.  
  1579. #ifndef FRENCH
  1580. MACRO {feb} {"Feb."}
  1581. #else FRENCH
  1582. MACRO {feb} {"f\'{e}v."}
  1583. #endif FRENCH
  1584.  
  1585. #ifndef FRENCH
  1586. MACRO {mar} {"March"}
  1587. #else FRENCH
  1588. MACRO {mar} {"mars"}
  1589. #endif FRENCH
  1590.  
  1591. #ifndef FRENCH
  1592. MACRO {apr} {"Apr."}
  1593. #else FRENCH
  1594. MACRO {apr} {"avr."}
  1595. #endif FRENCH
  1596.  
  1597. #ifndef FRENCH
  1598. MACRO {may} {"May"}
  1599. #else FRENCH
  1600. MACRO {may} {"mai"}
  1601. #endif FRENCH
  1602.  
  1603. #ifndef FRENCH
  1604. MACRO {jun} {"June"}
  1605. #else FRENCH
  1606. MACRO {jun} {"juin"}
  1607. #endif FRENCH
  1608.  
  1609. #ifndef FRENCH
  1610. MACRO {jul} {"July"}
  1611. #else FRENCH
  1612. MACRO {jul} {"juil."}
  1613. #endif FRENCH
  1614.  
  1615. #ifndef FRENCH
  1616. MACRO {aug} {"Aug."}
  1617. #else FRENCH
  1618. MACRO {aug} {"ao\^{u}t"}
  1619. #endif FRENCH
  1620.  
  1621. #ifndef FRENCH
  1622. MACRO {sep} {"Sep."}
  1623. #else FRENCH
  1624. MACRO {sep} {"sep."}
  1625. #endif FRENCH
  1626.  
  1627. #ifndef FRENCH
  1628. MACRO {oct} {"Oct."}
  1629. #else FRENCH
  1630. MACRO {oct} {"oct."}
  1631. #endif FRENCH
  1632.  
  1633. #ifndef FRENCH
  1634. MACRO {nov} {"Nov."}
  1635. #else FRENCH
  1636. MACRO {nov} {"nov."}
  1637. #endif FRENCH
  1638.  
  1639. #ifndef FRENCH
  1640. MACRO {dec} {"Dec."}
  1641. #else FRENCH
  1642. MACRO {dec} {"d\'{e}c."}
  1643. #endif FRENCH
  1644.  
  1645. #endif MONTH_FULL
  1646.  
  1647. # if 0
  1648. % Journals are either written out in full or abbreviated;
  1649. % the abbreviations are like those found in ACM publications.
  1650. %
  1651. % To get a completely different set of abbreviations, it may be best to make
  1652. % a separate .bib file with nothing but those abbreviations; users could then
  1653. % include that file name as the first argument to the \bibliography command
  1654. # endif 0
  1655.  
  1656. #if JOUR_FULL
  1657.  
  1658. MACRO {acmcs} {"ACM Computing Surveys"}
  1659.  
  1660. MACRO {acta} {"Acta Informatica"}
  1661.  
  1662. MACRO {cacm} {"Communications of the ACM"}
  1663.  
  1664. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1665.  
  1666. MACRO {ibmsj} {"IBM Systems Journal"}
  1667.  
  1668. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1669.  
  1670. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1671.  
  1672. MACRO {ieeetcad}
  1673.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1674.  
  1675. MACRO {ipl} {"Information Processing Letters"}
  1676.  
  1677. MACRO {jacm} {"Journal of the ACM"}
  1678.  
  1679. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1680.  
  1681. MACRO {scp} {"Science of Computer Programming"}
  1682.  
  1683. MACRO {sicomp} {"SIAM Journal on Computing"}
  1684.  
  1685. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1686.  
  1687. MACRO {tods} {"ACM Transactions on Database Systems"}
  1688.  
  1689. MACRO {tog} {"ACM Transactions on Graphics"}
  1690.  
  1691. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1692.  
  1693. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1694.  
  1695. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1696.  
  1697. MACRO {tcs} {"Theoretical Computer Science"}
  1698.  
  1699. #ifdef FRENCH
  1700. MACRO {tsi} {"Technique et Science Informatiques"}
  1701.  
  1702. #endif FRENCH
  1703. #else !JOUR_FULL
  1704.  
  1705. MACRO {acmcs} {"ACM Comput. Surv."}
  1706.  
  1707. MACRO {acta} {"Acta Inf."}
  1708.  
  1709. MACRO {cacm} {"Commun. ACM"}
  1710.  
  1711. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1712.  
  1713. MACRO {ibmsj} {"IBM Syst. J."}
  1714.  
  1715. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1716.  
  1717. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1718.  
  1719. MACRO {ieeetcad}
  1720.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1721.  
  1722. MACRO {ipl} {"Inf. Process. Lett."}
  1723.  
  1724. MACRO {jacm} {"J. ACM"}
  1725.  
  1726. MACRO {jcss} {"J. Comput. Syst. Sci."}
  1727.  
  1728. MACRO {scp} {"Sci. Comput. Programming"}
  1729.  
  1730. MACRO {sicomp} {"SIAM J. Comput."}
  1731.  
  1732. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1733.  
  1734. MACRO {tods} {"ACM Trans. Database Syst."}
  1735.  
  1736. MACRO {tog} {"ACM Trans. Gr."}
  1737.  
  1738. MACRO {toms} {"ACM Trans. Math. Softw."}
  1739.  
  1740. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1741.  
  1742. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1743.  
  1744. MACRO {tcs} {"Theoretical Comput. Sci."}
  1745.  
  1746. MACRO {tsi} {"Technique et Science Informatiques"}
  1747.  
  1748. #endif JOUR_FULL
  1749.  
  1750. # if 0
  1751. % Now we read in the .BIB entries.
  1752. # endif 0
  1753.  
  1754. READ
  1755.  
  1756. # if 0
  1757. % The sortify function converts to lower case after purify$ing; it's
  1758. % used in sorting and in computing alphabetic labels after sorting
  1759. # endif 0
  1760.  
  1761. #if SORTED
  1762.  
  1763. FUNCTION {sortify}
  1764. { purify$
  1765.   "ll" change.case$
  1766. }
  1767.  
  1768. #endif SORTED
  1769.  
  1770. # if 0
  1771. % This long comment applies only to alphabetic labels
  1772. %
  1773. % The format.lab.names function makes a short label by using the initials of
  1774. % the von and Last parts of the names (but if there are more than four names,
  1775. % (i.e., people) it truncates after three and adds a "*";
  1776. % it also adds a "*" if the last of multiple authors is "others").
  1777. % If there is only one name, and its von and Last parts combined have just
  1778. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1779. % we take the first three letters of the last name.
  1780. % In the LONG and ALPHA3 styles, only the name of the first author is
  1781. % considered.
  1782. % In the KEY and SKEY styles, the label is equal to the citation key.
  1783. %
  1784. % format.lab.names(s) ==
  1785. %  BEGIN
  1786. %    numnames := num.names$(s)
  1787. %    if numnames > 1 then
  1788. %        if numnames > 4 then
  1789. %        namesleft := 3
  1790. %        else
  1791. %        namesleft := numnames
  1792. %        nameptr := 1
  1793. %        nameresult := ""
  1794. %        while namesleft > 0
  1795. %          do
  1796. %        if (name_ptr = numnames) and
  1797. %            format.name$(s, nameptr, "{ff}{vv}{ll}{jj}") = "others"
  1798. %            then nameresult := nameresult * "*"
  1799. %            else nameresult := nameresult *
  1800. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1801. %        nameptr := nameptr + 1
  1802. %        namesleft := namesleft - 1
  1803. %          od
  1804. %        if numnames > 4 then
  1805. %        nameresult := nameresult * "*"
  1806. %    else
  1807. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1808. %        if substring$(t, 2, 1) = "" then    % there's just one name-token
  1809. %        nameresult := substring$(purify$(format.name$(s, 1, "{ll}")),
  1810. %                                    1, 3)
  1811. %        else
  1812. %        nameresult := t
  1813. %        fi
  1814. %    fi
  1815. %    nameresult
  1816. %  END
  1817. %
  1818. % Here is a function for calculating the preliminary label of an entry.
  1819. % It is formed by calculating format.lab.names on the author field
  1820. % (or on the editor field if there is no author, or using the first three
  1821. % letters of the key field if there is no editor either), and appending the
  1822. % last two characters (digits) of the year.  It is an error if there is no
  1823. % author, editor or key field, and we use the first three letters of the title
  1824. % in desperation when this happens.  The resulting label is purify$ed, except
  1825. % for possibly a "*" if there are too many authors.
  1826. %
  1827. % This function also calculates the version of this label to be used in sorting
  1828. %
  1829. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1830. % otherwise identical labels, but we can't calculated those "extra.label"s
  1831. % until after sorting.
  1832. %
  1833. % calc.label ==
  1834. %  BEGIN
  1835. %    if missing$(author) then
  1836. %        if missing$(editor) then
  1837. %        if missing$(key) then
  1838. %            top$("Warning: need a key to make a label in " * cite$)
  1839. %            label := substring$(purify$(field.or.null(title)), 1, 3)
  1840. %        else
  1841. %            label := substring$(purify$(key), 1, 3)
  1842. %        fi
  1843. %        else
  1844. %        label := format.lab.names(editor)
  1845. %        fi
  1846. %    else
  1847. %        label := format.lab.names(author)
  1848. %    fi
  1849. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1850. %        % assuming we will also sort, we calculate a sort.label
  1851. %    sort.label := sortify(label)
  1852. %  END
  1853. %
  1854. % In the case of the SKEY style, compute the sort.label as above, but do
  1855. %       label := cite$
  1856. % In the case of the KEY style, the above computation is done but not used.
  1857. % It really should be taken out, but what the heck.
  1858. # endif 0
  1859.  
  1860. #if LAB_ALPH
  1861.  
  1862. FUNCTION {format.lab.names}
  1863. { 's swap$ :=
  1864. #if !ALPHA_LONG
  1865.   'numnames s num.names$ :=
  1866.   numnames #1 >
  1867.     { numnames #4 >
  1868.     { 'namesleft #3 := }
  1869.     { 'namesleft numnames := }
  1870.       if$
  1871.       'nameptr #1 :=
  1872.       'nameresult "" :=
  1873.     { namesleft #0 > }
  1874.     { nameptr numnames =
  1875.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  1876.         { 'nameresult nameresult "*" * := }
  1877.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1878.           * :=
  1879.         }
  1880.           if$
  1881.         }
  1882.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1883.           * :=
  1884.         }
  1885.       if$
  1886.       'nameptr nameptr #1 + :=
  1887.       'namesleft namesleft #1 - :=
  1888.     }
  1889.       while$
  1890.       numnames #4 >
  1891.     { 'nameresult nameresult "*" * := }
  1892.     'skip$
  1893.       if$
  1894.     }
  1895.     { 
  1896. #endif ALPHA_LONG
  1897.  
  1898.       't s #1 "{v{}}{l{}}" format.name$ :=
  1899.  
  1900.       'nameresult
  1901.       t #2 #1 substring$ "" =
  1902.  
  1903. #if ALPHA_LONG<2
  1904.     { s #1 "{ll}" format.name$ purify$ #1 #3 substring$ }
  1905. #else ALPHA_LONG
  1906.         { s #1 "{ll}" format.name$ purify$ }
  1907. #endif ALPHA_LONG
  1908.  
  1909.     { t }
  1910.       if$
  1911.       :=
  1912.  
  1913. #if !ALPHA_LONG
  1914.     }
  1915.   if$
  1916. #endif ALPHA_LONG
  1917.  
  1918.   nameresult
  1919. }
  1920.  
  1921. FUNCTION {calc.label}
  1922. { 'label
  1923.   author missing$
  1924.     { editor missing$
  1925.     { key missing$
  1926.         { "Warning: need a key to make a label in " cite$ * top$
  1927.           title field.or.null purify$ #1 #3 substring$
  1928.         }
  1929.         { key purify$ #1 #3 substring$ }
  1930.       if$
  1931.     }
  1932.     { editor format.lab.names }
  1933.       if$
  1934.     }
  1935.     { author format.lab.names }
  1936.   if$
  1937. #if ALPHA_LONG>1
  1938.   " " year field.or.null purify$ #-1 #2 substring$ *
  1939. #else ALPHA_LONG<=1
  1940.   year field.or.null purify$ #-1 #2 substring$
  1941. #endif ALPHA_LONG
  1942.   *
  1943.   :=
  1944. #if SORTED
  1945.   'sort.label label sortify :=
  1946. #endif SORTED
  1947. #if LBKEYS
  1948.   'label cite$ :=
  1949. #endif LBKEYS
  1950. }
  1951.  
  1952. # if 0
  1953. % It doesn't seem like a particularly good idea to use an order-of-citation
  1954. % reference list when using alphabetic labels, but we need to have a
  1955. % special pass to calculate labels when this happens.
  1956. # endif 0
  1957.  
  1958. #if !SORTED
  1959.  
  1960. ITERATE {calc.label}
  1961.  
  1962. #endif !SORTED
  1963.  
  1964. #endif LAB_ALPH
  1965.  
  1966. # if 0
  1967. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1968. % The presort key contains a number of "sortify"ed strings, concatenated
  1969. % with multiple blanks between them.  This makes things like "brinch  per"
  1970. % come before "brinch hansen  per"
  1971. %
  1972. % The fields used here are:
  1973. % the sort.label for alphabetic labels (as set by calc.label),
  1974. % followed by the author names (or editor names, if those are missing,
  1975. % or the key field if both are), followed by the first bit
  1976. % of the title (chopping off a leading "The ", "A ", or "An ").
  1977. % Names are formatted: Von Last First Junior.
  1978. % The names within a part will be separated by a single blank
  1979. % (such as "brinch hansen"), two will separate the name parts themselves
  1980. % (except the von and last), three will separate the names,
  1981. % and four will separate the names from the title (and label, if alphabetic).
  1982. %
  1983. % The sort.format.names function takes an argument that should be in
  1984. % BibTeX name format, and returns a string containing "   "-separated
  1985. % names in the format described above.  The function is almost the same
  1986. % as format.names.
  1987. # endif 0
  1988.  
  1989. #if SORTED
  1990.  
  1991. FUNCTION {sort.format.names}
  1992. { 's swap$ :=
  1993.   'nameptr #1 :=
  1994.   'nameresult "" :=
  1995.   'numnames s num.names$ :=
  1996.   'namesleft numnames :=
  1997.     { namesleft #0 > }
  1998.     { nameptr #1 >
  1999.     { 'nameresult nameresult "   " * := }
  2000.     'skip$
  2001.       if$
  2002. #if NAME_FULL
  2003.       't s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ :=
  2004. #else
  2005.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  2006. #endif NAME_FULL
  2007.       nameptr numnames = t "others" = and
  2008.     { 'nameresult nameresult "et al" * := }
  2009.     { 'nameresult nameresult t sortify * := }
  2010.       if$
  2011.       'nameptr nameptr #1 + :=
  2012.       'namesleft namesleft #1 - :=
  2013.     }
  2014.   while$
  2015.   nameresult
  2016. }
  2017.  
  2018. # if 0
  2019. % The chop.word(w,len,s) function returns either s or, if the first len
  2020. % letters of s equals w (this comparison is done in the third line of the
  2021. % function's definition), it returns that part of s after w.
  2022. # endif 0
  2023.  
  2024. INTEGERS {len}
  2025.  
  2026. FUNCTION {chop.word}
  2027. { 's swap$ :=
  2028.   'len swap$ :=
  2029.   s #1 len substring$ =
  2030.     { s len #1 + global.string.max substring$ }
  2031.     { s }
  2032.   if$
  2033. }
  2034.  
  2035. # if 0
  2036. % The sort.format.title function returns the argument,
  2037. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2038. % The chop.word function uses s, so we need another string variable, t
  2039. # endif 0
  2040.  
  2041. FUNCTION {sort.format.title}
  2042. { 't swap$ :=
  2043.   "A " #2
  2044.     "An " #3
  2045.       "The " #4 t chop.word
  2046.     chop.word
  2047.   chop.word
  2048.   #1 global.string.max substring$
  2049.   sortify
  2050. }
  2051.  
  2052. # if 0
  2053. % There is a limit on the length of an entry string variable, which
  2054. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  2055. % take at most that many characters of the constructed key, and hope
  2056. % there aren't many references that match to that many characters!
  2057. # endif 0
  2058.  
  2059. FUNCTION {presort}
  2060. {
  2061. #if LAB_ALPH
  2062.   calc.label
  2063.   sort.label
  2064.   "    "
  2065.   *
  2066. #endif LAB_ALPH
  2067.   author missing$
  2068.     { editor missing$
  2069.     { key field.or.null sortify }
  2070.     { editor sort.format.names }
  2071.       if$
  2072.     }
  2073.     { author sort.format.names }
  2074.   if$
  2075. #if LAB_ALPH
  2076.   *
  2077. #endif LAB_ALPH
  2078.   "    "
  2079.   *
  2080.   title field.or.null
  2081.   sort.format.title
  2082.   *
  2083.   #1 entry.string.max substring$
  2084.   'sort.key$ swap$ :=
  2085. }
  2086.  
  2087. ITERATE {presort}
  2088.  
  2089. # if 0
  2090. % And now we can sort
  2091. # endif 0
  2092.  
  2093. SORT
  2094.  
  2095. #endif SORTED
  2096.  
  2097. # if 0
  2098. % This long comment applies only to alphabetic labels, when sorted
  2099. %
  2100. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2101. % and 'b's and so forth if required.  This involves two passes: a forward
  2102. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2103. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2104. % are 'b's).  However this is not necessary in the 'skeys' style.
  2105. % We have to keep track of the longest (in width$ terms) label, for use
  2106. % by the "thebibliography" environment.
  2107. %
  2108. % VAR: longest.label, last.sort.label, next.extra: string
  2109. %      longest.label.width, last.extra.num: integer
  2110. %
  2111. % initialize.longest.label ==
  2112. %  BEGIN
  2113. %    longest.label := ""
  2114. %    last.sort.label := ""
  2115. %    next.extra := ""
  2116. %    longest.label.width := 0
  2117. %    last.extra.num := 0
  2118. %  END
  2119. %
  2120. % forward.pass ==
  2121. %  BEGIN
  2122. %    if last.sort.label = sort.label then
  2123. %        last.extra.num := last.extra.num + 1
  2124. %        extra.label := int.to.chr$(last.extra.num)
  2125. %    else
  2126. %        last.extra.num := chr.to.int$("a")
  2127. %        extra.label := ""
  2128. %        last.sort.label := sort.label
  2129. %    fi
  2130. %  END
  2131. %
  2132. % reverse.pass ==
  2133. %  BEGIN
  2134. %    if next.extra = "b" then
  2135. %        extra.label := "a"
  2136. %    fi
  2137. %    label := label * extra.label
  2138. %    if width$(label) > longest.label.width then
  2139. %        longest.label := label
  2140. %        longest.label.width := width$(label)
  2141. %    fi
  2142. %    next.extra := extra.label
  2143. %  END
  2144. # endif 0
  2145.  
  2146. #if LAB_ALPH
  2147.  
  2148. #if SORTED
  2149.  
  2150. STRINGS { longest.label last.sort.label next.extra }
  2151.  
  2152. INTEGERS { longest.label.width last.extra.num }
  2153.  
  2154. FUNCTION {initialize.longest.label}
  2155. { 'longest.label "" :=
  2156.   'last.sort.label "" :=
  2157.   'next.extra "" :=
  2158.   'longest.label.width #0 :=
  2159.   'last.extra.num #0 :=
  2160. }
  2161.  
  2162. #   ifndef SKEY
  2163. FUNCTION {forward.pass}
  2164. { last.sort.label sort.label =
  2165.     { 'last.extra.num last.extra.num #1 + :=
  2166.       'extra.label last.extra.num int.to.chr$ :=
  2167.     }
  2168.     { 'last.extra.num "a" chr.to.int$ :=
  2169.       'extra.label "" :=
  2170.       'last.sort.label sort.label :=
  2171.     }
  2172.   if$
  2173. }
  2174. #   endif SKEY
  2175.  
  2176. FUNCTION {reverse.pass}
  2177. #  ifndef SKEY
  2178.   next.extra "b" =
  2179.     { 'extra.label "a" := }
  2180.     'skip$
  2181.   if$
  2182.   'label label extra.label * :=
  2183. #  endif SKEY
  2184.   label width$ longest.label.width >
  2185.     { 'longest.label label :=
  2186.       'longest.label.width label width$ :=
  2187.     }
  2188.     'skip$
  2189.   if$
  2190.   'next.extra extra.label :=
  2191. }
  2192.  
  2193. EXECUTE {initialize.longest.label}
  2194.  
  2195. #   ifndef SKEY
  2196. ITERATE {forward.pass}
  2197. #   endif SKEY
  2198.  
  2199. REVERSE {reverse.pass}
  2200.  
  2201.  
  2202. #else !SORTED
  2203.  
  2204. # if 0
  2205. % It still doesn't seem like a good idea to use an order-of-citation
  2206. % reference list when using alphabetic labels, but when this happens we
  2207. % must compute the longest label
  2208. # endif 0
  2209.  
  2210. STRINGS {longest.label}
  2211.  
  2212. INTEGERS {longest.label.width}
  2213.  
  2214. FUNCTION {initialize.longest.label}
  2215. { 'longest.label "" :=
  2216.   'longest.label.width #0 :=
  2217. }
  2218.  
  2219. FUNCTION {longest.label.pass}
  2220. { label width$ longest.label.width >
  2221.     { 'longest.label label :=
  2222.       'longest.label.width label width$ :=
  2223.     }
  2224.     'skip$
  2225.   if$
  2226. }
  2227.  
  2228. EXECUTE {initialize.longest.label}
  2229.  
  2230. ITERATE {longest.label.pass}
  2231.  
  2232. #endif SORTED
  2233.  
  2234. #else !LAB_ALPH
  2235.  
  2236. # if 0
  2237. % Now comes the computation for numeric labels.
  2238. % We use either the sorted order or original order.
  2239. % We still have to keep track of the longest (in width$ terms) label, for use
  2240. % by the "thebibliography" environment.
  2241. # endif 0
  2242.  
  2243. STRINGS {longest.label}
  2244.  
  2245. INTEGERS { number.label longest.label.width }
  2246.  
  2247. FUNCTION {initialize.longest.label}
  2248. { 'longest.label "" :=
  2249.   'number.label #1  :=
  2250.   'longest.label.width #0 :=
  2251. }
  2252.  
  2253. FUNCTION {longest.label.pass}
  2254. { 'label number.label int.to.str$ :=
  2255.   'number.label number.label #1 + :=
  2256.   label width$ longest.label.width >
  2257.     { 'longest.label label :=
  2258.       'longest.label.width label width$ :=
  2259.     }
  2260.     'skip$
  2261.   if$
  2262. }
  2263.  
  2264. EXECUTE {initialize.longest.label}
  2265.  
  2266. ITERATE {longest.label.pass}
  2267.  
  2268. #endif LAB_ALPH
  2269.  
  2270. # if 0
  2271. % Now we're ready to start writing the .BBL file.
  2272. % First we write the `preamble' containing the command
  2273. %     \begin{thebibliography}{...}
  2274. % where the `...' is the longest label.
  2275. %
  2276. % Then we call init.state.consts, for use by the output routines.
  2277. # endif 0
  2278.  
  2279. FUNCTION {preamble}
  2280. { "\begin{thebibliography}{"  longest.label  * "}" * write$
  2281.   newline$
  2282. }
  2283.  
  2284. EXECUTE {preamble}
  2285.  
  2286. EXECUTE {init.state.consts}
  2287.  
  2288. # if 0
  2289. % Now we produce the output for all the entries
  2290. # endif 0
  2291.  
  2292. ITERATE {call.type$}
  2293.  
  2294. # if 0
  2295. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2296. # endif 0
  2297.  
  2298. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  2299.  
  2300. EXECUTE {finish.up}
  2301.